NonZeroInt
@Serializable(with = NonZeroIntSerializer::class)
@Since(version = KotoolsTypesVersion.V1_1_0)
Represents an integer number of type Int that is other than zero.
You can use the toNonZeroInt function for creating an instance of this type.
Serialization and deserialization
The serialization and deserialization processes of this type behave like for the Int type.
Here's an example of Kotlin code that encodes and decodes this type using the JavaScript Object Notation (JSON) format from kotlinx.serialization:
val number: NonZeroInt = 123.toNonZeroInt()
.getOrThrow()
val encoded: String = Json.encodeToString(number)
println(encoded) // 123
val decoded: NonZeroInt = Json.decodeFromString(encoded)
println(decoded == number) // true
Content copied to clipboard
Inheritors
Types
Link copied to clipboard
object Companion
Contains declarations for holding or building a NonZeroInt.
Functions
Link copied to clipboard
@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
Returns the negative of this integer number.